﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AdministratorsByDepartments.aspx.cs" Inherits="GPSTrackingWebsiteManager.Manager.Pages.AdministratorsByDepartments" %>

<%@ Register Src="~/Manager/UserControls/AdministratorsSearch.ascx" TagPrefix="uc1" TagName="AdministratorsSearch" %>

<!DOCTYPE html>

<link href="../../Css/GPSTrackingWebsite.css" rel="stylesheet" />
<link href="../../Css/messi.css" rel="stylesheet" />
<script src="../../Javascript/jquery-1.11.1.min.js"></script>
<script src="../../Javascript/messi.js"></script>
<script src="../../Javascript/Custom.js"></script>
<script src="../../Javascript/WindowMessageManager.js"></script>

<telerik:RadScriptBlock ID="RadScriptBlock3" runat="server">
    <script type="text/javascript">
        function resizeGrid() {
            var height = (window.innerHeight) - 25;
            var tableView = $find("<%=DeparmentsGrid.ClientID %>");
            tableView.get_element().style.height = (height)/2 + "px";

            var tableView2 = $find("<%=AdministratorsSelectedGrid.ClientID %>");
            tableView2.get_element().style.height = (height - (height) / 2) + "px";
            
            document.getElementById('HiddenFieldHeight').value = (window.innerHeight);
        }

        //Windows Message Manager 
        var objWindowsMessageManager = new WindowsMessageManager();



    </script>
</telerik:RadScriptBlock>


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Asociar Departamento al Administrador</title>
</head>
<body onresize="resizeGrid()" style="overflow: hidden">
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
         <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="DeparmentsGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rmpAdministratorsByDepartments" LoadingPanelID="RadAjaxLoadingPanel1" UpdatePanelCssClass="" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
               <telerik:AjaxSetting AjaxControlID="AdministratorsSelectedGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="AdministratorsSelectedGrid" LoadingPanelID="RadAjaxLoadingPanel1" UpdatePanelCssClass="" />
                        <telerik:AjaxUpdatedControl ControlID="HiddenFieldError" /> 
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>
        <asp:HiddenField ID="HiddenFieldHeight" runat="server" Value="518" />
        <asp:HiddenField ID="HiddenFieldError" runat="server" Value="" />
        
        <telerik:RadTabStrip ID="rtsAdministratorsByDepartments" runat="server" SelectedIndex="0" MultiPageID="rmpAdministratorsByDepartments" ></telerik:RadTabStrip>
        <telerik:RadMultiPage ID="rmpAdministratorsByDepartments" runat="server" SelectedIndex="0">
        <telerik:RadPageView ID="rpvAdministratorsByDepartments" runat="server">

        <div>
                <telerik:RadGrid ID="DeparmentsGrid" runat="server" AllowFilteringByColumn="False" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" Height="100%" Width="100%" OnNeedDataSource="DeparmentsGrid_NeedDataSource" OnSelectedIndexChanged="DeparmentsGrid_SelectedIndexChanged" AllowSorting="true" GroupingSettings-CaseSensitive="false" OnItemCommand="DeparmentsGrid_ItemCommand">
                    <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
                         <Selecting AllowRowSelect="True"></Selecting><ClientEvents OnPopUpShowing="PopUpShowing" />
                    </ClientSettings>
                    <MasterTableView EditMode="PopUp" EditFormSettings-PopUpSettings-Modal="true" EditFormSettings-CaptionFormatString="Modo Edición" CommandItemDisplay="TopAndBottom" NoMasterRecordsText="No hay registros" AllowFilteringByColumn="true" TableLayout="Auto">
                    <CommandItemTemplate>
                        <div style="padding: 5px 5px;"> Departamentos: 
                                <asp:LinkButton ID="lbClearFilters" runat="server" OnClick="lbClearFilters_Click"  Visible='<%# !DeparmentsGrid.MasterTableView.IsItemInserted %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/mixx-icon.png"/>Limpiar Filtros</asp:LinkButton>                                                                               
                        </div>                        
                    </CommandItemTemplate>
                        <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </RowIndicatorColumn>

                        <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </ExpandCollapseColumn>

                        <Columns>
                            <telerik:GridButtonColumn UniqueName="SelectColumn" CommandName="Select" Text="Seleccionar" HeaderStyle-Width="20px" ButtonType="ImageButton" ImageUrl="../../Template/Icons/16px/User-Group-Blue-icon.png" />
                            <telerik:GridBoundColumn DataField="DepartmentId" Display="false" FilterControlAltText="Filter DepartmentId column" HeaderText="DepartmentId" UniqueName="DepartmentId" ReadOnly="true" ForceExtractValue="Always">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="DepartmentIdSource.Name" FilterControlAltText="Filter Name column" HeaderText="Nombre" MaxLength="50" UniqueName="Name" HeaderStyle-Width="200px" FilterControlWidth="180px" CurrentFilterFunction="Contains" ShowFilterIcon="false" ItemStyle-Width="10px" AutoPostBackOnFilter="true" >
                                 <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                    <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                                </ColumnValidationSettings>
                            </telerik:GridBoundColumn>                            
                        </Columns>

                    </MasterTableView>
                    <ClientSettings EnableRowHoverStyle="true">
                        <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True">
                        </Scrolling>
                    </ClientSettings>
                    <FilterMenu EnableImageSprites="False"></FilterMenu>
                </telerik:RadGrid>
        <br/>
        <telerik:RadGrid ID="AdministratorsSelectedGrid" runat="server" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" Height="100%" Width="100%" OnNeedDataSource="AdministratorsSelectedGrid_NeedDataSource" OnDeleteCommand="AdministratorsSelectedGrid_DeleteCommand" AllowSorting="true" GroupingSettings-CaseSensitive="false">
            <MasterTableView EditMode="PopUp" EditFormSettings-PopUpSettings-Modal="true" EditFormSettings-CaptionFormatString="Modo Edición" CommandItemDisplay="TopAndBottom" NoMasterRecordsText="No hay registros" AllowFilteringByColumn="true" TableLayout="Auto">
            <CommandItemTemplate>
                <div style="padding: 5px 5px;"> Administradores Asociados: 
                        <asp:LinkButton ID="lbAddAdmin" runat="server" OnClientClick="OpenAdministratorsSearch()"><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/text-plus-icon.png"/>Asociar más Administradores</asp:LinkButton>
                        <asp:LinkButton ID="lbClearFiltersAdmin" runat="server" OnClick="lbClearFiltersAdmin_Click"  Visible='<%# !AdministratorsSelectedGrid.MasterTableView.IsItemInserted %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/mixx-icon.png"/>Limpiar Filtros</asp:LinkButton>                                                                               
                        <asp:LinkButton ID="lbShowError" runat="server" OnClick="lbShowError_Click" Visible='<%# HiddenFieldError.Value == string.Empty ? false : true %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/bug-icon.png"/>Error Técnico</asp:LinkButton>                                                                                                               
                </div>                        
            </CommandItemTemplate>

            <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>

            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>

            <Columns>
                <telerik:GridButtonColumn HeaderStyle-Width="25px" ConfirmText="¿Desea eliminar el registro?" ConfirmDialogType="RadWindow" ConfirmDialogHeight="120" ConfirmDialogWidth="270" ConfirmTitle="Eliminar" ButtonType="ImageButton" CommandName="Delete" Text="Eliminar" ItemStyle-Width="20px" />
                <telerik:GridBoundColumn DataField="AdminUsername" HeaderText="Admin Username" UniqueName="AdminUsername" HeaderStyle-Width="150px" MaxLength="30" FilterControlWidth="130px" CurrentFilterFunction="Contains" ShowFilterIcon="false" ItemStyle-Width="10px" AutoPostBackOnFilter="true" >
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Name" HeaderText="Nombre" UniqueName="Name" HeaderStyle-Width="200px" MaxLength="50" FilterControlWidth="180px" CurrentFilterFunction="Contains" ShowFilterIcon="false" ItemStyle-Width="10px" AutoPostBackOnFilter="true" >
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="FirstName" HeaderText="Apellido1" UniqueName="FirstName" HeaderStyle-Width="200px" MaxLength="50" FilterControlWidth="180px" CurrentFilterFunction="Contains" ShowFilterIcon="false" ItemStyle-Width="10px" AutoPostBackOnFilter="true" >
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="LastName" HeaderText="Apellido2" UniqueName="LastName" HeaderStyle-Width="200px" MaxLength="50" FilterControlWidth="180px" CurrentFilterFunction="Contains" ShowFilterIcon="false" ItemStyle-Width="10px" AutoPostBackOnFilter="true" >
                </telerik:GridBoundColumn>
            </Columns>

            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
            </EditFormSettings>

            <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
        </MasterTableView>
        <ClientSettings EnableRowHoverStyle="true">
            <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True">
            </Scrolling>  <Selecting AllowRowSelect="True"></Selecting><ClientEvents OnPopUpShowing="PopUpShowing" />
        </ClientSettings>

        <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>

        <FilterMenu EnableImageSprites="False"></FilterMenu>
    </telerik:RadGrid>

    </div>
    </telerik:RadPageView>
    </telerik:RadMultiPage>
    
    <uc1:AdministratorsSearch runat="server" ID="uscAdministratorsSearch" IsMultipleSelects="true" CalledBy="AdministratorsByDepartments" IsClearGridAfterClose="true" OnOnAcceptEvent="uscAdministratorsSearch_OnAcceptEvent" OnOnCancelEvent="uscAdministratorsSearch_OnCancelEvent"/>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
    </form>
</body>
</html>
